package com.clear.prototype.shallowcopy.constructor;

import com.clear.prototype.shallowcopy.Song;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * 具体原型类：实现一个克隆自己的操作（方法）
 */
@Data
public class Playlist {
    private Long id;
    private String name;
    private List<Song> songs = new ArrayList<>();

    public Playlist() {
    }

    public void add(Song song) {
        songs.add(song);
    }

    // 用于浅拷贝的构造器
    public Playlist(Playlist sourcePlayList) {
        this.id = sourcePlayList.getId();
        this.name = sourcePlayList.getName();
        this.songs = sourcePlayList.getSongs();
    }
}
